clear
set more off
set matsize 2000
set scheme modern

*	Change CD
*	global root         	"..."
	global source			="$root/raw"
	global temp				="$root/temp"
	global code				="$root/code"
	global output			="$root/output"

use "$temp/sweden_final", clear

********************************************************************************
*Figure 2c*
********************************************************************************

reg conservative_e s_largefarms s_agriculture popdensity i.year i.county_id, cluster(county)
	local coef_main=round(_b[s_largefarms],.001)
	local t = _b[s_largefarms]/_se[s_largefarms]
	local t_round = round(`t',.001)
	local p =2*ttail(e(df_r),abs(`t')) // computes p-value

	if `p'<.01 {
		local signstars = "***"
	}
	else if `p'>=.01 & `p'<.05 {
		local signstars = "**"
	}
	else if `p'>=.05 & `p'<.1 {
		local signstars = "*"
	}
	else if `p'>= .1 {
		local signstars = ""
	}
	
	local string_main= "{&beta}="+"`coef_main'"+"`signstars'"
	display "string_main"

	local t_main = "t=`t_round'"
	display "t_main"
	
	
local ytitle "Votes conservative (in %)"
local xtitle "Large landowners (in %)"	
binscatter conservative_e s_largefarms, n(100) control(s_agriculture popdensity i.year i.county_id) ytitle(`ytitle') xtitle(`xtitle') text(21.2 20 "`string_main'", color(black) place(e)) text(20.8 20 "`t_main'", color(black) place(e))

 graph export "$output/figure2c.pdf", replace
 
 
reg conservative_e s_largefarms s_agriculture popdensity i.year i.county_id, cluster(county)
sum conservative_e
sum s_largefarms
di  (-.1575475 *r(sd))/14.41989

reg conservative_e s_noble s_agriculture popdensity i.year i.county_id, cluster(county)
sum conservative_e
sum s_noble
di  (-.0432846*r(sd))/28.34574

********************************************************************************
*Figure 2d*
********************************************************************************

reg conservative_e s_noble s_agriculture popdensity i.year i.county_id, cluster(county)
	local coef_main=round(_b[s_noble],.001)
	local t = _b[s_noble]/_se[s_noble]
	local t_round = round(`t',.001)
	local p =2*ttail(e(df_r),abs(`t')) // computes p-value

	if `p'<.01 {
		local signstars = "***"
	}
	else if `p'>=.01 & `p'<.05 {
		local signstars = "**"
	}
	else if `p'>=.05 & `p'<.1 {
		local signstars = "*"
	}
	else if `p'>= .1 {
		local signstars = ""
	}
	
	local string_main= "{&beta}="+"`coef_main'"+"`signstars'"
	display "string_main"

	local t_main = "t=`t_round'"
	display "t_main"
	
	
local ytitle "Votes conservative (in %)"
local xtitle "Land owned by nobility (in %)"	
binscatter conservative_e s_noble, n(100) control(s_agriculture popdensity i.year i.county_id) ytitle(`ytitle') xtitle(`xtitle') text(21.2 60 "`string_main'", color(black) place(e)) text(20.8 60 "`t_main'", color(black) place(e)) 
 graph export "$output/figure2d.pdf", replace
 
 
 


********************************************************************************
*Figure 3b
********************************************************************************

replace nazi_e = nazi_e*100

reg nazi_e s_largefarms s_agriculture popdensity i.county_id, cluster(county)
	local coef_main=round(_b[s_largefarms],.001)
	local t = _b[s_largefarms]/_se[s_largefarms]
	local t_round = round(`t',.001)
	local p =2*ttail(e(df_r),abs(`t')) // computes p-value

	if `p'<.01 {
		local signstars = "***"
	}
	else if `p'>=.01 & `p'<.05 {
		local signstars = "**"
	}
	else if `p'>=.05 & `p'<.1 {
		local signstars = "*"
	}
	else if `p'>= .1 {
		local signstars = ""
	}
	
	local string_main= "{&beta}="+"`coef_main'"+"`signstars'"
	display "string_main"

	local t_main = "t=`t_round'"
	display "t_main"
	
	
local ytitle "Nazi (in %)"
local xtitle "Large landowners (in %)"	
binscatter nazi_e s_largefarms, n(40) control(s_agriculture popdensity i.county_id) ytitle(`ytitle') xtitle(`xtitle') text(.75 18  "`string_main'", color(black) place(e)) text(.72 18  "`t_main'", color(black) place(e)) 
 graph export "$output/figure3b.pdf", replace
 

********************************************************************************
*Figure 4c
********************************************************************************

reg turnout s_largefarms s_agriculture popdensity i.year i.county_id, cluster(county)
	local coef_main=round(_b[s_largefarms],.001)
	local t = _b[s_largefarms]/_se[s_largefarms]
	local t_round = round(`t',.001)
	local p =2*ttail(e(df_r),abs(`t')) // computes p-value

	if `p'<.01 {
		local signstars = "***"
	}
	else if `p'>=.01 & `p'<.05 {
		local signstars = "**"
	}
	else if `p'>=.05 & `p'<.1 {
		local signstars = "*"
	}
	else if `p'>= .1 {
		local signstars = ""
	}
	
	local string_main= "{&beta}="+"`coef_main'"+"`signstars'"
	display "string_main"

	local t_main = "t=`t_round'"
	display "t_main"
	
	
local ytitle "Turnout (in %)"
local xtitle "Large landowners (in %)"	
binscatter turnout s_largefarms, n(100) control(s_agriculture popdensity i.year i.county_id) ytitle(`ytitle') xtitle(`xtitle') text(63 20 "`string_main'", color(black) place(e)) text(62.2 20 "`t_main'", color(black) place(e)) 
 graph export "$output/figure4c.pdf", replace
 
reg turnout s_largefarms s_agriculture popdensity i.year i.county_id, cluster(county)
sum turnout
sum s_largefarms 
di (.1784341*r(sd))/12.87999
 
********************************************************************************
*Appendix Table A1 (part for Sweden)
********************************************************************************

sum s_largefarms s_noble if year==1911, d
sum nazi_e if year==1936, d
sum turnout conservative_e, d

 
********************************************************************************
*Appendix Table A4
********************************************************************************
eststo sweden1: reg conservative_e s_largefarms popdensity s_agriculture i.year, cluster(county_id)
	estadd local YearFE 	"\checkmark"
	estadd local Control 	"\checkmark"
	quietly: estadd ysumm

eststo sweden2: reg conservative_e s_largefarms popdensity s_agriculture i.year i.county_id, cluster(county_id)
	estadd local RegionFE 	"\checkmark"
	estadd local YearFE 	"\checkmark"
	estadd local Control 	"\checkmark"
	quietly: estadd ysumm

eststo sweden3: reg conservative_e s_noble popdensity s_agriculture i.year , cluster(county_id)
	estadd local YearFE 	"\checkmark"
	estadd local Control 	"\checkmark"
	quietly: estadd ysumm

eststo sweden4: reg conservative_e s_noble popdensity s_agriculture i.year i.county_id , cluster(county_id)
	estadd local RegionFE 	"\checkmark"
	estadd local YearFE 	"\checkmark"
	estadd local Control 	"\checkmark"
	quietly: estadd ysumm


	
local titles " Dep. var. & \multicolumn{4}{c}{Votes Conservatives (in \%)} \\" 

#delimit ;
estout sweden1 sweden2 sweden3 sweden4  using "$output/appendix_tab04.tex", 
	replace 			
	starlevels(* 0.10 ** 0.05 *** 0.01)
	label
	collabels(none) 
	keep (s_largefarms s_noble)
	style(tex) cells(b(star fmt(3)) se(fmt(3) par))
	stats(ymean ysd Control YearFE RegionFE r2  N , fmt(%9.2f %9.2f  %~3s %~3s  %~3s %9.2f %9.0f) 
	labels("Mean dependent variable" "SD dependent variable" "Controls" "Year FE" "County FE" "R-squared"  "Observations" ))
	mlabels("" "" "" "", span prefix(\multicolumn{@span}{c}{) suffix(}) numbers)
	prehead("\begin{tabularx}{1\textwidth}{Xcccc}" "\toprule `titles' ")
	posthead(" \cmidrule(lr){2-5} ") prefoot("\midrule") postfoot("\bottomrule" "\end{tabularx}");
	#delimit cr
	*/		
	
	

********************************************************************************
*Appendix Table A7
********************************************************************************
eststo nazi1: reg nazi_e s_largefarms popdensity s_agriculture i.year, cluster(county_id)
	estadd local YearFE 	"\checkmark"
	estadd local Control 	"\checkmark"
	quietly: estadd ysumm

eststo nazi2: reg nazi_e s_largefarms popdensity s_agriculture i.year i.county_id, cluster(county_id)
	estadd local RegionFE 	"\checkmark"
	estadd local YearFE 	"\checkmark"
	estadd local Control 	"\checkmark"
	quietly: estadd ysumm

eststo nazi3: reg nazi_e s_noble popdensity s_agriculture i.year , cluster(county_id)
	estadd local YearFE 	"\checkmark"
	estadd local Control 	"\checkmark"
	quietly: estadd ysumm

eststo nazi4: reg nazi_e s_noble popdensity s_agriculture i.year i.county_id , cluster(county_id)
	estadd local RegionFE 	"\checkmark"
	estadd local YearFE 	"\checkmark"
	estadd local Control 	"\checkmark"
	quietly: estadd ysumm


	
local titles " Dep. var. & \multicolumn{4}{c}{Votes Nazi party (in \%)} \\" 

#delimit ;
estout nazi1 nazi2 nazi3 nazi4  using "$output/appendix_tab07.tex", 
	replace 			
	starlevels(* 0.10 ** 0.05 *** 0.01)
	label
	collabels(none) 
	keep (s_largefarms s_noble)
	style(tex) cells(b(star fmt(3)) se(fmt(3) par))
	stats(ymean ysd Control YearFE RegionFE r2  N , fmt(%9.2f %9.2f  %~3s %~3s  %~3s %9.2f %9.0f) 
	labels("Mean dependent variable" "SD dependent variable" "Controls" "Year FE" "County FE" "R-squared"  "Observations" ))
	mlabels("" "" "" "", span prefix(\multicolumn{@span}{c}{) suffix(}) numbers)
	prehead("\begin{tabularx}{1\textwidth}{Xcccc}" "\toprule `titles' ")
	posthead(" \cmidrule(lr){2-5} ") prefoot("\midrule") postfoot("\bottomrule" "\end{tabularx}");
	#delimit cr
	*/		



********************************************************************************
*Appendix Table A10
********************************************************************************
eststo turnout1: reg turnout s_largefarms popdensity s_agriculture i.year, cluster(county_id)
	estadd local YearFE 	"\checkmark"
	estadd local Control 	"\checkmark"
	quietly: estadd ysumm

eststo turnout2: reg turnout s_largefarms popdensity s_agriculture i.year i.county_id, cluster(county_id)
	estadd local RegionFE 	"\checkmark"
	estadd local YearFE 	"\checkmark"
	estadd local Control 	"\checkmark"
	quietly: estadd ysumm

eststo turnout3: reg turnout s_noble popdensity s_agriculture i.year , cluster(county_id)
	estadd local YearFE 	"\checkmark"
	estadd local Control 	"\checkmark"
	quietly: estadd ysumm

eststo turnout4: reg turnout s_noble popdensity s_agriculture i.year i.county_id , cluster(county_id)
	estadd local RegionFE 	"\checkmark"
	estadd local YearFE 	"\checkmark"
	estadd local Control 	"\checkmark"
	quietly: estadd ysumm


	
local titles " Dep. var. & \multicolumn{4}{c}{Turnout (in \%)} \\" 

#delimit ;
estout turnout1 turnout2 turnout3 turnout4 using "$output/appendix_tab10.tex", 
	replace 			
	starlevels(* 0.10 ** 0.05 *** 0.01)
	label
	collabels(none) 
	keep (s_largefarms s_noble)
	style(tex) cells(b(star fmt(3)) se(fmt(3) par))
	stats(ymean ysd Control YearFE RegionFE r2  N , fmt(%9.2f %9.2f  %~3s %~3s  %~3s %9.2f %9.0f) 
	labels("Mean dependent variable" "SD dependent variable" "Controls" "Year FE" "County FE" "R-squared"  "Observations" ))
	mlabels("" "" "" "", span prefix(\multicolumn{@span}{c}{) suffix(}) numbers)
	prehead("\begin{tabularx}{1\textwidth}{Xcccc}" "\toprule `titles' ")
	posthead(" \cmidrule(lr){2-5} ") prefoot("\midrule") postfoot("\bottomrule" "\end{tabularx}");
	#delimit cr
	*/		


********************************************************************************
*Appendix Table A13
********************************************************************************

foreach year in 1911 1914 1915 1917 1920 1921 1924 1928 1932 1936 1940 1944 {
	eststo sweden`year': reg conservative_e s_largefarms popdensity s_agriculture i.county_id if year==`year', cluster(county_id)
		estadd local RegionFE "\checkmark"
		estadd local Control 	"\checkmark"
		quietly: estadd ysumm
}

local titles " & 1911 & 3/1914 & 9/1914 & 1917 & 1920 & 1921 & 1924 & 1928 & 1932 & 1936 & 1940 & 1944 \\" 

#delimit ;
estout sweden1911 sweden1914 sweden1915 sweden1917 sweden1920 sweden1921 sweden1924 sweden1928 sweden1932 sweden1936 sweden1940 sweden1944 using "$output/appendix_tab13.tex", 
	replace 			
	starlevels(* 0.10 ** 0.05 *** 0.01)
	label
	collabels(none) 
	keep (s_largefarms)
	style(tex) cells(b(star fmt(3)) se(fmt(3) par))
	stats(ymean ysd Control RegionFE r2  N , fmt(%9.2f %9.2f %~3s %~3s %9.2f %9.0f) 
	labels("Mean dependent variable" "SD dependent variable" "Controls" "County FE" "R-squared"  "Observations" ))
	mlabels("" "" "" "" "" "" "" "" "" "" "" "", span prefix(\multicolumn{@span}{c}{) suffix(}) numbers)
	prehead("\begin{tabularx}{1\textwidth}{Xcccccccccccc}" "\toprule `titles' ")
	posthead(" \cmidrule(lr){2-13} ") prefoot("\midrule") postfoot("\bottomrule" "\end{tabularx}");
	#delimit cr
	*/		

	
********************************************************************************
*Appendix Table A14
********************************************************************************
eststo alt1: reg conservative_e toppfyrk popdensity s_agriculture i.year, cluster(county_id)
	estadd local YearFE 	"\checkmark"
	estadd local Control 	"\checkmark"
	quietly: estadd ysumm

eststo alt2: reg conservative_e toppfyrk popdensity s_agriculture i.year i.county_id, cluster(county_id)
	estadd local RegionFE 	"\checkmark"
	estadd local YearFE 	"\checkmark"
	estadd local Control 	"\checkmark"
	quietly: estadd ysumm
	

eststo alt3: reg conservative_e toppagrarianfyrk popdensity s_agriculture i.year, cluster(county_id)
	estadd local YearFE 	"\checkmark"
	estadd local Control 	"\checkmark"
	quietly: estadd ysumm

eststo alt4: reg conservative_e toppagrarianfyrk popdensity s_agriculture i.year i.county_id, cluster(county_id)
	estadd local RegionFE 	"\checkmark"
	estadd local YearFE 	"\checkmark"
	estadd local Control 	"\checkmark"
	quietly: estadd ysumm

local titles " Dep. var. & \multicolumn{4}{c}{Votes Conservatives (in \%)} \\" 

#delimit ;
estout alt1 alt2 alt3 alt4  using "$output/appendix_tab14.tex", 
	replace 			
	starlevels(* 0.10 ** 0.05 *** 0.01)
	label
	collabels(none) 
	keep (toppfyrk toppagrarianfyrk)
	style(tex) cells(b(star fmt(3)) se(fmt(3) par))
	stats(ymean ysd Control YearFE RegionFE r2  N , fmt(%9.2f %9.2f  %~3s %~3s  %~3s %9.2f %9.0f) 
	labels("Mean dependent variable" "SD dependent variable" "Controls" "Year FE" "County FE" "R-squared"  "Observations" ))
	mlabels("" "" "" "", span prefix(\multicolumn{@span}{c}{) suffix(}) numbers)
	prehead("\begin{tabularx}{1\textwidth}{Xcccc}" "\toprule `titles' ")
	posthead(" \cmidrule(lr){2-5} ") prefoot("\midrule") postfoot("\bottomrule" "\end{tabularx}");
	#delimit cr
	*/		

	
********************************************************************************
*Appendix Table A17
********************************************************************************
gen outlier=0
sum s_largefarms, d
replace outlier=1 if s_largefarms>r(p95) & s_largefarms!=.

eststo sample1: reg conservative_e 	s_largefarms s_agriculture popdensity i.year 	i.county_id if outlier==0, cluster(county)
	estadd local RegionFE 	"\checkmark"
	estadd local YearFE 	"\checkmark"
	estadd local Control 	"\checkmark"
	estadd local Outlier	"\checkmark"
	quietly: estadd ysumm
	
eststo sample2: reg nazi_e 			s_largefarms s_agriculture popdensity 			i.county_id if outlier==0 & year==1936, cluster(county)
	estadd local RegionFE 	"\checkmark"
	estadd local YearFE 	"\checkmark"
	estadd local Control 	"\checkmark"
	estadd local Outlier	"\checkmark"
	quietly: estadd ysumm
	
eststo sample3: reg turnout 		s_largefarms s_agriculture popdensity i.year 	i.county_id if outlier==0, cluster(county)
	estadd local RegionFE 	"\checkmark"
	estadd local YearFE 	"\checkmark"
	estadd local Control 	"\checkmark"
	estadd local Outlier	"\checkmark"
	quietly: estadd ysumm

gen north=0
foreach county in Norrbotten  Västerbotten Jämtland  Västernorrland Gävleborg {
replace north = 1  if county=="`county'"
}

eststo sample4: reg conservative_e 	s_largefarms s_agriculture popdensity i.year 	i.county_id if north==0, cluster(county)
	estadd local RegionFE 	"\checkmark"
	estadd local YearFE 	"\checkmark"
	estadd local Control 	"\checkmark"
	estadd local North		"\checkmark"
	quietly: estadd ysumm
	
eststo sample5: reg nazi_e 			s_largefarms s_agriculture popdensity 			i.county_id if north==0 & year==1936, cluster(county)
	estadd local RegionFE 	"\checkmark"
	estadd local YearFE 	"\checkmark"
	estadd local Control 	"\checkmark"
	estadd local North		"\checkmark"
	quietly: estadd ysumm
	
eststo sample6: reg turnout 		s_largefarms s_agriculture popdensity i.year 	i.county_id if north==0, cluster(county)
	estadd local RegionFE 	"\checkmark"
	estadd local YearFE 	"\checkmark"
	estadd local Control 	"\checkmark"
	estadd local North		"\checkmark"
	quietly: estadd ysumm
	
local titles " Dep. var. & \multicolumn{2}{c}{Conservatives (in \%)}  & \multicolumn{2}{c}{Nazi (in \%)}  & \multicolumn{2}{c}{Turnout (in \%)}  \\" 

#delimit ;
estout sample1 sample4 sample2 sample5 sample3 sample6 using "$output/appendix_tab17.tex", 
	replace 			
	starlevels(* 0.10 ** 0.05 *** 0.01)
	label
	collabels(none) 
	keep (s_largefarms)
	style(tex) cells(b(star fmt(3)) se(fmt(3) par))
	stats(ymean ysd Control YearFE RegionFE Outlier North r2  N , fmt(%9.2f %9.2f  %~3s %~3s  %~3s  %~3s  %~3s %9.2f %9.0f) 
	labels("Mean dependent variable" "SD dependent variable" "Controls" "Year FE" "County FE" "Without outliers" "Without northern part" "R-squared"  "Observations" ))
	mlabels("" "" "" "" "" "", span prefix(\multicolumn{@span}{c}{) suffix(}) numbers)
	prehead("\begin{tabularx}{1\textwidth}{Xcccccc}" "\toprule `titles' ")
	posthead(" \cmidrule(lr){2-7} ") prefoot("\midrule") postfoot("\bottomrule" "\end{tabularx}");
	#delimit cr
	*/		
	
********************************************************************************
*Appendix Table A19
********************************************************************************

eststo suit1: reg conservative_e 	s_largefarms s_agriculture 					popdensity i.year 	i.county_id, cluster(county)
	estadd local RegionFE 	"\checkmark"
	estadd local YearFE 	"\checkmark"
	estadd local Control 	"\checkmark"
	quietly: estadd ysumm
	
eststo suit2: reg conservative_e 	s_largefarms avg_suitability  s_agriculture popdensity i.year 	i.county_id, cluster(county)
	estadd local RegionFE 	"\checkmark"
	estadd local YearFE 	"\checkmark"
	estadd local Control 	"\checkmark"
	quietly: estadd ysumm
	
eststo suit3: reg nazi_e 			s_largefarms s_agriculture 					popdensity 			i.county_id,  cluster(county)
	estadd local RegionFE 	"\checkmark"
	estadd local YearFE 	"\checkmark"
	estadd local Control 	"\checkmark"
	quietly: estadd ysumm
	
eststo suit4: reg nazi_e 			s_largefarms avg_suitability s_agriculture 	popdensity 			i.county_id,  cluster(county)
	estadd local RegionFE 	"\checkmark"
	estadd local YearFE 	"\checkmark"
	estadd local Control 	"\checkmark"
	quietly: estadd ysumm
	
eststo suit5: reg turnout 		s_largefarms s_agriculture 					popdensity i.year 	i.county_id , cluster(county)
	estadd local RegionFE 	"\checkmark"
	estadd local YearFE 	"\checkmark"
	estadd local Control 	"\checkmark"
	quietly: estadd ysumm
	
eststo suit6: reg turnout 		s_largefarms avg_suitability s_agriculture popdensity i.year 	i.county_id , cluster(county)
	estadd local RegionFE 	"\checkmark"
	estadd local YearFE 	"\checkmark"
	estadd local Control 	"\checkmark"
	quietly: estadd ysumm

local titles " Dep. var. & \multicolumn{2}{c}{Conservatives (in \%)}  & \multicolumn{2}{c}{Nazi (in \%)}  & \multicolumn{2}{c}{Turnout (in \%)}  \\" 

#delimit ;
estout suit1 suit2 suit3 suit4 suit5 suit6 using "$output/appendix_tab19.tex", 
	replace 			
	starlevels(* 0.10 ** 0.05 *** 0.01)
	label
	collabels(none) 
	keep (s_largefarms avg_suitability)
	style(tex) cells(b(star fmt(3)) se(fmt(3) par))
	stats(ymean ysd Control YearFE RegionFE r2  N , fmt(%9.2f %9.2f  %~3s %~3s  %~3s %9.2f %9.0f) 
	labels("Mean dependent variable" "SD dependent variable" "Controls" "Year FE" "County FE" "R-squared"  "Observations" ))
	mlabels("" "" "" "" "" "", span prefix(\multicolumn{@span}{c}{) suffix(}) numbers)
	prehead("\begin{tabularx}{1\textwidth}{Xcccccc}" "\toprule `titles' ")
	posthead(" \cmidrule(lr){2-7} ") prefoot("\midrule") postfoot("\bottomrule" "\end{tabularx}");
	#delimit cr
	*/		
	

********************************************************************************
*Appendix Table A21
********************************************************************************
eststo left1: reg left_e s_largefarms popdensity s_agriculture i.year, cluster(county_id)
	estadd local YearFE 	"\checkmark"
	estadd local Control 	"\checkmark"
	quietly: estadd ysumm

eststo left2: reg left_e s_largefarms popdensity s_agriculture i.year i.county_id, cluster(county_id)
	estadd local RegionFE 	"\checkmark"
	estadd local YearFE 	"\checkmark"
	estadd local Control 	"\checkmark"
	quietly: estadd ysumm

eststo left3: reg left_e s_noble popdensity s_agriculture i.year , cluster(county_id)
	estadd local YearFE 	"\checkmark"
	estadd local Control 	"\checkmark"
	quietly: estadd ysumm

eststo left4: reg left_e s_noble popdensity s_agriculture i.year i.county_id , cluster(county_id)
	estadd local RegionFE 	"\checkmark"
	estadd local YearFE 	"\checkmark"
	estadd local Control 	"\checkmark"
	quietly: estadd ysumm

	
local titles " Dep. var. & \multicolumn{4}{c}{Votes Left (in \%)} \\" 

#delimit ;
estout left1 left2 left3 left4  using "$output/appendix_tab21.tex", 
	replace 			
	starlevels(* 0.10 ** 0.05 *** 0.01)
	label
	collabels(none) 
	keep (s_largefarms s_noble)
	style(tex) cells(b(star fmt(3)) se(fmt(3) par))
	stats(ymean ysd Control YearFE RegionFE r2  N , fmt(%9.2f %9.2f  %~3s %~3s  %~3s %9.2f %9.0f) 
	labels("Mean dependent variable" "SD dependent variable" "Controls" "Year FE" "County FE" "R-squared"  "Observations" ))
	mlabels("" "" "" "", span prefix(\multicolumn{@span}{c}{) suffix(}) numbers)
	prehead("\begin{tabularx}{1\textwidth}{Xcccc}" "\toprule `titles' ")
	posthead(" \cmidrule(lr){2-5} ") prefoot("\midrule") postfoot("\bottomrule" "\end{tabularx}");
	#delimit cr
	*/		

********************************************************************************
*Appendix Table A20
********************************************************************************
import excel "$source/sweden_district.xlsx", sheet(data) firstrow clear

encode County, gen(county_id) 

label variable estateshare "Large farmers among farmers (in \%)"
label variable nobleshare "Land owned by nobility (in \%)"

eststo civil1: reg union estateshare PopDens agriculture , cluster(county_id)
	estadd local Control 	"\checkmark"
	quietly: estadd ysumm

eststo civil2: reg union estateshare PopDens agriculture  i.county_id , cluster(county_id)
	estadd local RegionFE 	"\checkmark"
	estadd local Control 	"\checkmark"
	quietly: estadd ysumm

eststo civil3: reg union nobleshare PopDens agriculture , cluster(county_id)
	estadd local Control 	"\checkmark"
	quietly: estadd ysumm

eststo civil4: reg union nobleshare PopDens agriculture  i.county_id , cluster(county_id)
	estadd local RegionFE 	"\checkmark"
	estadd local Control 	"\checkmark"
	quietly: estadd ysumm



	
local titles " Dep. var. & \multicolumn{4}{c}{Membership unions (in \%)} \\" 

#delimit ;
estout civil1 civil2 civil3 civil4  using "$output/appendix_tab20.tex", 
	replace 			
	starlevels(* 0.10 ** 0.05 *** 0.01)
	label
	collabels(none) 
	keep (estateshare nobleshare)
	style(tex) cells(b(star fmt(3)) se(fmt(3) par))
	stats(ymean ysd Control RegionFE r2  N , fmt(%9.2f %9.2f  %~3s  %~3s %9.2f %9.0f) 
	labels("Mean dependent variable" "SD dependent variable" "Controls"  "County FE" "R-squared"  "Observations" ))
	mlabels("" "" "" "", span prefix(\multicolumn{@span}{c}{) suffix(}) numbers)
	prehead("\begin{tabularx}{1\textwidth}{Xcccc}" "\toprule `titles' ")
	posthead(" \cmidrule(lr){2-5} ") prefoot("\midrule") postfoot("\bottomrule" "\end{tabularx}");
	#delimit cr
	*/		
